﻿using System.Collections.Generic;
using System.Data;
using POS.BusinessEntities;

namespace POS.DataObjects
{
    public class DOUbicacion : DOBase
    {
        #region Declarations

        private const string getListSP = "ProvinciaGetListByPaisId";

        #endregion

        #region Methods: Public

        public virtual IList<BEEntidad> GetProvinciaList(int paisId)
        {
            var result = new List<BEEntidad>();

            var command = Db.GetStoredProcCommand(getListSP);
            Db.AddInParameter(command, "@paisId", DbType.Int32, paisId);
            var data = Db.ExecuteDataSet(command);

            if (data.Tables.Count == 1)
            {
                foreach (DataRow row in data.Tables[0].Rows)
                    result.Add(CreateEntityFromDataRow<BEEntidad>(row));
            }
            return result;
        }

        #endregion
    }
}
